/*******************************************************************************
 * Copyright (c) 2007 University of Oslo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University of Oslo - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.diagram.sequence.sedi.figures;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;

/**
 * @author Andreas Limyr
 * @author frankd@ifi.uio.no
 */
public class CoregionFigure extends InteractionFragmentFigure1 {

    private static final int TAP_HEIGHT = 7;

    private static final int WIDTH = 11;
    private static final int DEFAULT_HEIGHT = 40;
    private static final int MIN_HEIGHT = 2 * TAP_HEIGHT + 5;

    protected void paintFigure(Graphics g) {
        Rectangle r = getBounds().getCopy();
        g.setBackgroundColor(this.getBackgroundColor());
        g.setForegroundColor(this.getForegroundColor());
        g.drawLine(r.x, r.y, r.right() - 1, r.y);
        g.drawLine(r.x, r.bottom() - 1, r.right() - 1, r.bottom() - 1);
        g.drawLine(r.x, r.y, r.x, r.y + TAP_HEIGHT);
        g.drawLine(r.right() - 1, r.y + TAP_HEIGHT, r.right() - 1, r.y);
        g.drawLine(r.right() - 1, r.bottom() - 1, r.right() - 1, r.bottom() - 1 - TAP_HEIGHT);
        g.drawLine(r.x, r.bottom() - 1, r.x, r.bottom() - 1 - TAP_HEIGHT);
    }

    public Rectangle getPreferredBounds(Rectangle suggestedBounds) {
        int height =
                suggestedBounds.height == 0 ? DEFAULT_HEIGHT
                        : (suggestedBounds.height < MIN_HEIGHT ? MIN_HEIGHT
                                : suggestedBounds.height);
        return new Rectangle(suggestedBounds.x, suggestedBounds.y, WIDTH, height);
    }

    // --- ILabeledFigure ---

    public Rectangle getLabelBounds() {
        return null; // not used
    }

    public void setLabel(String labelText) {
        // not used
    }
}
